package com.iona.servlets;

import java.io.IOException;
import java.util.List;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.iona.dao.DisciplineDAO;
import com.iona.domain.Discipline;
import com.iona.json.JSONException;
import com.iona.json.builders.DisciplineBuilder;

@WebServlet("/dfeeder")
public class DisciplineFeederServlet extends FeederServlet implements Servlet {
	private static final long serialVersionUID = 1L;

	@Override
	public void init(ServletConfig config) throws ServletException {
		super.init(config);
		setTransactional(false);
	}

	@Override
	public Object doFeed(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException,
			JSONException {
		List<Discipline> findAll = new DisciplineDAO().findAll();
		Object build = new DisciplineBuilder(findAll).build();
		return build;
	}

}
